package org.sandbox2.domain.loan;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.ManyToMany;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.roo.addon.entity.RooEntity;
import org.springframework.roo.addon.javabean.RooJavaBean;
import org.springframework.roo.addon.tostring.RooToString;
import org.springframework.transaction.annotation.Transactional;
import org.sandbox2.reference.LoanType;
import javax.persistence.Enumerated;

@RooJavaBean
@RooToString
@RooEntity(finders = { "findLoansByBorrowerId" })
public class Loan {

    protected Double principal;

    protected Integer paymentTime;

    protected Double rate;

    @Temporal(TemporalType.TIMESTAMP)
    @DateTimeFormat(style = "S-")
    protected Date startDate;

    protected String description;

    protected Long borrowerId;

    @ManyToMany(cascade = CascadeType.ALL)
    protected List<PaymentDetail> paymentDetails = new ArrayList<PaymentDetail>();

    @Enumerated
    private LoanType loanType;

    @Transactional
    public void create() {
    }
}
